(function(window) {
	function readBlobAsDataURL(blob, callback) {
		var a = new FileReader();
		a.onload = function() {
			callback(a.result);
		};
		a.readAsDataURL(blob);
	}

	function convertImg(img, cback) {
		var image = JSON.parse(img);
		var arr = [];
		for(var i in image) {
			arr[i] = image[i];
		}
		if(arr.length > 0) {
			var ia = new Uint8Array(arr);
			var myresizedImage = (new Blob([ia], {
				type: "image/png"
			}));
			readBlobAsDataURL(myresizedImage, function(dataurl) {
				cback(dataurl);
			});
		}
	}
	window.convertImg = convertImg;
})(window);